package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.WantBuyOrderConsumeProp;
import com.sc.nft.enums.SecondWantBuyOrderConsumePropStatusEnum;
import com.sc.nft.mapper.WantBuyOrderConsumePropMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 刘国航
 * @desc
 * @since 2024/12/19 20:02
 */
@Slf4j
@Repository
public class WantBuyOrderConsumePropDao extends ServiceImpl<WantBuyOrderConsumePropMapper, WantBuyOrderConsumeProp> {

    public List<WantBuyOrderConsumeProp> queryByOrderIdAndStatus(Long wantBuyOrderId, SecondWantBuyOrderConsumePropStatusEnum status) {
        LambdaQueryWrapper<WantBuyOrderConsumeProp> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WantBuyOrderConsumeProp::getWantBuyOrderId, wantBuyOrderId);
        queryWrapper.eq(WantBuyOrderConsumeProp::getStatus, status);
        return list(queryWrapper);
    }

    public List<WantBuyOrderConsumeProp> queryByOrderIdAndStatusLimit(Long wantBuyOrderId, SecondWantBuyOrderConsumePropStatusEnum status, Integer limit) {
        LambdaQueryWrapper<WantBuyOrderConsumeProp> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WantBuyOrderConsumeProp::getWantBuyOrderId, wantBuyOrderId);
        queryWrapper.eq(WantBuyOrderConsumeProp::getStatus, status);
        queryWrapper.orderByAsc(WantBuyOrderConsumeProp::getSort);
        queryWrapper.last("limit " + limit);
        return list(queryWrapper);
    }

}
